package cn.yj.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 永健
 * @since 2022-02-09 09:45
 */
@Configuration
public class OrderQueueConfig {

    @Bean(name = "ORDER_QUEUE")
    public Queue queue(){
        return new Queue("ORDER_QUEUE",true,false,false);
    }


    @Bean(name = "TEST_QUEUE")
    public Queue testQueue(){
        return new Queue("TEST_QUEUE",true,false,false);
    }


    @Bean("ORDER_EXCHANGE")
    public Exchange exchange(){
        return new FanoutExchange("ORDER_EXCHANGE",true,false);
    }

    @Bean("ORDER_BINDING")
    public Binding binding(Queue ORDER_QUEUE,Exchange ORDER_EXCHANGE){
        return BindingBuilder.bind(ORDER_QUEUE).to(ORDER_EXCHANGE).with("").noargs();
    }

    @Bean
    public Binding bindingTest(Queue TEST_QUEUE,Exchange ORDER_EXCHANGE){
        return BindingBuilder.bind(TEST_QUEUE).to(ORDER_EXCHANGE).with("").noargs();
    }

}
